@extends('home.layout.index')
@section('content')

 <style>
  .abc{
    width:18px;
    height:20px;
    border:1px solid #1657A6;
    float:right;
    margin-top:0px;
    margin-right:2px;
    font-size:20px;
    size-color:pink;
    font-height:20px;
    display:block;
    }
    .hf:after{
      clear:both;
      content:'';
      display:block;
      width:0;
      height:0;
      visibility:hidden;
    }
    .hf{
      *zoom:1;
    }
    .hf-text{
      border: 1px solid #eee;
      display: block;
      height: 15px;
      width: 438px;
      padding: 5px;
      resize: none;
      color: #ccc;
      font-size:12px;
    }
    .hf-on .hf-text{
      height: 60px;
      color: #333;
      border:1px solid #ff8140;
    }
    .hf-btn{
      margin-right:100px;

      width: 65px;
      height: 26px;
      background: #CD8D3D;
      color: #ccc;
      font-size: 12px;
      display: none;
    }
    .hf-btn-on{
      background: #ff8140;
      color: #fff;
    }
    .hf-nub{
      margin-right:120px;
      padding: 3px 5px;
      color: #666;
      display: none;
    }
    .hf-on .hf-btn{
      display: inline;
    }
    .hf-on .hf-nub{
      display: inline;
    }
    .answer_answer{
      margin-top:10px;
    }
    .meg{
    width:90px;
    height:20px;
    color:#1657A6;
    padding:3px;
    line-height:20px;
    font-size:12px;
    margin-top:9px;
  }

</style>

<div id="container">
    <div class="content">

        <div class="aside">

<!-- 登录 -->
<div class="aside-section">
            <div id="userBaseInfo">
            <div class="aside-login">
                <div class="aside-login-txt2">262,071,640</div>
                <div class="aside-login-txt">问题已被解决</div>
                <a href="javascript:;" class="btn-aside-login s_login">QQ一键登录</a>
            </div>
        </div>
    </div>
<!-- //登录 -->
 <div id="aside_fix">
    <!-- 相关搜索 -->
    <div id="hint_search"></div>
    <!-- 精彩回答 -->
    <div id="topic_answer" style="min-height: 347px;"></div>
</div>
        </div>

        <div class="main">
            <div class="section">





<h1 id="question_title" class="detail-tit-box">
    <span class="detail-tit" id="question_title_val">{{$question['q_title']}}</span>
</h1>
  <!-- <textarea name="content" id="" cols="30" rows="10"></textarea> -->
    <pre id="question_content" class="detail-tit-info ">{!! $question['q_content'] !!}</pre>

<!-- ft-bar -->
<div class="ft-bar">
    <div class="ft-info-box">
        <div class="user-thumb-box">
                            <a href="" target="_blank" class="user-thumb getUserCard" data-uid="35356401"><img src="{{$q_userdetail['photo']}}" width="100%" height="100%" alt="头像"></a>
        </div>
        <div class="user-name-box">
                            <a href="" target="_blank" id="question_author" class="user-name">{{$q_userdetail['nickname']}}</a>
        </div>
        <div class="user-txt">
                        <span>{{$question['count']}}次浏览</span>
                        <span>{{$question['q_time']}}</span>
        </div>
    </div>
</div>
<!-- //ft-bar -->
    <!-- edit-reply///////////////////////// -->
    <!-- <div class="answer_box ipt-default "> -->
    <br><br>
    <h2 class="section-tit">最新回答
      <span>已有{{$question['count']}}条回答</span></h2>
      <a href="javascript:;" class=" meg" id="show_detail"> 查看回复 <i></i></a>



  <!-- 第一次遍历开始//////////////////////////////////////////////////////////////////////////////////////////////// -->
    @foreach($arr as $k=>$v)
    @if($v['qid']==$qid)
    <div class="section " style="height:">
  <div class="replay-wrap common_answers">
    <a name="pageLocation"></a>
    <div class="replay-section answer_item" data-id="6304616884071761062">
      <a name="aid6304616884071761062"></a>
      <div class="user-thumb-box">
        <a href="/home/userdetail/{{$v['uid']}}" target="_blank" class="user-thumb getUserCard " data-uid="35356401">
          <img src="{{$v['photo']}}" width="100%" height="100%" alt="头像"></a>
        <div id="userCard_347" class="userCard">
          <div>
            <div class="mycard-popup" style="top: auto; bottom: 0px;">
              <div class="mycard">
                <a href="/home/userdetail/{{$v['uid']}}" class="user-thumb">
                  <img src="{{$v['photo']}}" width="90" height="90" alt="头像"></a>
                <div class="mycard-name-box">
                  <a href="#" target="_blank" class="mycard-name"></a>
                  <span class="user-level-tag">{{$v['level']}}</span></div>
                <div class="tags">
                  <p>{{$v['description']}}</p>
                </div>
                <div class="mycard-bottom">
                  <div class="mycard-bottom-tab">
                    <div class="mycard-bottom-tit">回答数</div>
                    <span class="mycard-bottom-txt">{{$v['a_count']}}</span></div>
                  <div class="mycard-bottom-tab">
                    <div class="mycard-bottom-tit">提问数</div>
                    <span class="mycard-bottom-txt">{{$v['q_count']}}</span></div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <div class="replay-info">
        <div class="user-name-box">
          <a href="/home/user/question" target="_blank" class="user-name getUserCard" data-uid="35356401">{{$v['nickname']}}</a></div>
        <div class="user-txt"> {{$v['a_time']}}回答</div>
        <div class="toprgt-bar">
          <a href="javascript:;" class="btn-replay-edit">编辑
            <i></i>
          </a>
          <ul class="popup-lst" style="z-index: 3;">
            <li class="edit_question">
              <a href="javascript:void(0)" onclick="">完善回答</a></li>
            <li class="delete_item" data-type="answer" data-id="6304616884071761062">

              <a href="javascript:void(0)" onclick="delAnswer({{$v['a_id']}})">删除回答</a>
            </li>
          </ul>
        </div>

        <div class="toprgt-bar"></div>
        <pre class="replay-info-txt answer_con">
          <p>{{$v['a_content']}}</p>
        </pre>

         <div class="comment_wrap megclose">

        <div class="answer_answer">
<!-- 第二次遍历开始////////////////////////////////////////////////////////////////////////////////////////////////////// -->
        @if(isset($v['children']))
            @foreach($v['children'] as $v2)
            <div class="user-thumb-box">
                <a href="javascript:;">
                    <img src="{{$v2['photo']}}" width="20" height="20" alt="头像">
                </a>
            </div>
              <div class="">
                        <textarea cols="30" rows="1" placeholder="写下你的评论" class="edit-comment-txtarea"
                        maxlength="1000" autofocus="">{{$v2['a_content']}}
                        </textarea>
                        <input type="hidden" name="u" value="{{$v2['uid']}}" id="u">
                        <div class="err-txtarea-prompt">
              </div>
             <ul id="pn">
          <div class="hf">
          <!-- <div class="ft-info-box"> -->
          <form action="/home/reply" method="post">
            {{csrf_field()}}
            <input type="hidden" name="a_id" value="{{$v2['a_id']}}">
            <input type="hidden" name="a_time" value="{{date('Y-m-d H:i:s')}}">
            <input type="hidden" name="qid" value="{{$v['qid']}}">
            <input type="hidden" name="uid" value="{{session('login')}}">
            <textarea type="text" class="hf-text" autocomplete="off" maxlength="100" style="width:300px;height:20px;"  name="a_content"></textarea>
            <!-- <button class="hf-btn" type="submit"><a href="" onclick="">回复</a></button> -->
            <input type="submit" value="提交" class="hf-btn">

             <a href="javascript:;" class="ht-btn" data-num="0" id="text">
            <span class="ht-nub"></span>
                <i>
                </i>
              </a>
              <div id="c_6305673337201164402" class="comment-wrap"></div>
          </form>

          </div>
        </ul>
            <div class="replay-info">
                <div class="ipt-default">
  <!-- 第三次遍历开始///////////////////////////////////////////////////////////////////////////////////////////////// -->
                  @if(isset($v2['children']))
                   @foreach($v2['children'] as $v3)
                   <div class="user-thumb-box">
                      <a href="javascript:;">
                          <img src="{{$v3['photo']}}" width="20" height="20" alt="头像">
                      </a>
                  </div>
                    <div class="">
                        <textarea cols="30" rows="1" placeholder="写下你的评论" class="edit-comment-txtarea"
                        maxlength="1000" autofocus="">{{$v3['a_content']}}
                        </textarea>
                        <input type="hidden" name="u" value="{{$v3['uid']}}" id="u">
                        <div class="err-txtarea-prompt">
                        </div>

                         @endforeach
                        @endif
  <!-- 第三次遍历结束////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
                    </div>
                </div>
            </div>

        </div>

         @endforeach
        @endif
<!-- 第二次遍历结束//////////////////////////////////////////////////////////////////////////////////////////////////// -->
    </div>
        <div class="ft-bar opera_area">
        <ul id="pn">
          <div class="hf">
          <!-- <div class="ft-info-box"> -->
          <form action="/home/reply" method="post">
            {{csrf_field()}}
            <input type="hidden" name="a_id" value="{{$v['a_id']}}">
            <input type="hidden" name="a_time" value="{{date('Y-m-d H:i:s')}}">
            <input type="hidden" name="qid" value="{{$v['qid']}}">
            <input type="hidden" name="uid" value="{{session('login')}}">
            <textarea type="text" class="hf-text" autocomplete="off" maxlength="100" style="width:300px;height:20px;"  name="a_content"></textarea>
            <!-- <button class="hf-btn" type="submit"><a href="" onclick="">回复</a></button> -->
            <input type="submit" value="提交" class="hf-btn">

             <a href="javascript:;" class="ht-btn" data-num="0" id="text">
            <span class="ht-nub"></span>
                <i>
                </i>
              </a>
              <div id="c_6305673337201164402" class="comment-wrap"></div>
          </form>

          </div>
        </ul>
          <div class="ft-btn-box  self ">
               <ul>
                      <li><img src="/home/zan.gif" alt="赞" style="display:none;" class="good"></li>
                     <li style="height:5px;"><font color="green"> 2 </font> </li>
                     <li><a href="javascript:void(0);" class="btn-up like_btn   dim " data-type="1" title="赞">赞</a></li>
                </ul>
                <ul>
                      <li><img src="/home/paizhuan.gif" alt="拍砖" style="display:none;" class="bad"></li>
                     <li style="height:5px;"><font color="red"> 0 </font> </li>
                     <li><a href="javascript:void(0);" class="btn-down like_btn   dim " data-type="2" title="呵呵" >呵呵</a></li>
                </ul>
            </a>
          </div>
        </div>
        <div id="c_6304616884071761062" class="comment-wrap hide"></div>
      </div>
    </div>
  </div>
</div>

@endif
 @endforeach
    <!-- 第一次遍历结束////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
    <!-- //edit-reply ///////////////////////-->

            </div>


            <!-- section -->
            <div class="section  hide ">



            </div>
            <!-- //section -->

            <!-- 底部相关 -->
            <div id="relates_box"></div>
            <div class="ad-activity-wrap " style="display:block;">
              <div class="abc" style="background-color:pink;">×</div>
                <a href="/" class="ad-activity-thumb">知之为知之，不知为不知，是智也！</a>
            </div>

        </div>
    </div>
    <script  src="/h/js/jquery-1.8.3.min.js"></script>
  <script type="text/javascript">
    $('a').one('click',function(){
      // 获取票数.parent().prev()
      var piaos = $(this).parent().prev().find('font').html();
      var s = ++piaos;
     $(this).parent().prev().find('font').html(s);
      $(this).attr('disabled','disabled');
      $(this).css('cursor','not-allowed');
     $(this).parent().prev().prev().find('img').css('display','block');
     setTimeout(function(){ $(this).parent().prev().prev().find('img').remove('img'); },2000);
    })

   $(document).ready(function(){
    $('.abc').click(function(){
    $('.ad-activity-wrap').css('display','none');
    })

   })
    $(function(){
    $('.meg').click(function(){
    $(".megclose").toggle("slow",function(){

        })
       });
   })

    $(document).ready(function(){
      // var arr=getDocument.
    $('#myform').submit(function(){
     if($('textarea').val()==""){
      alert('不能提交空数据???');
     }else{
      alert('回复成功');
     }
    })

   })
          function delAnswer(id){

            layer.confirm('是否确认删除？', {
                btn: ['确认','取消'] //按钮
            }, function(){
                //            jQuery.post(url,data,success(data, textStatus, jqXHR),dataType)
                $.post('{{url('/home/answer')}}/'+id,{'_token':'{{csrf_token()}}','_method':'delete'},function(data){
                    //console.log(data);
                    //  删除成功
                    if(data.status == 0){
                        layer.msg(data.msg, {icon: 6});
                        location.href = location.href;
                    }else{
                        layer.msg(data.msg, {icon: 5});
                        location.href = location.href;
                    }
                });

            }, function(){

            });
        }
           $(document).ready(function(){
    $('.hf-text').focus(function(){
      // alert($);
    $('.hf').toggleClass('hf-on');
    })

   })
    </script>
    <script type="text/javascript">
 // 在页面加载完后立即执行多个函数。
 function addloadEvent(func){
 var oldonload=window.onload;
 if(typeof window.onload !="function"){
  window.onload=func;
 }
 else{
  window.onload=function(){
  if(oldonload){
   oldonload();
  }
  func();
  }
 }
 }
 addloadEvent(b);
 function b(){
 var pn=document.getElementById("pn");
 var lists=pn.children;

//回复评论
 function reply(box){
 //获取评论框
 var textarea=box.getElementsByTagName("textarea")[0];

 comment.appendChild(div);
 //评论后初始化textarea输入框
 textarea.value="评论…";
 textarea.parentNode.className="hf";
 }

 //操作回复
 function operateReply(el){
 //每条评论
 var comment=el.parentNode.parentNode.parentNode;
 //整个状态
 var box=comment.parentNode.parentNode.parentNode;
 //评论框
 var textarea=box.getElementsByTagName("textarea")[0];

 //点击的innerHTML
 var txt=el.innerHTML;
 //判断当前点击的是否为回复
 if(txt=="回复"){
 //评论框触发焦点事件 也就是变高
 textarea.onfocus();
 //内容变为回复+当前人的名字
 textarea.value="回复 "+user.innerHTML;
 //调用键盘事件
 textarea.onkeyup();
 }else{
 //否则就是删除节点
 remove(comment);
 }
 }
  for(var i=0;i<lists.length;i++){
 //全部事件代理
 lists[i].onclick=function(e){
 //获取当前点击事件
 var e=e||window.event;
 var el=e.srcElement;
 if(!el){
 el=e.target;//兼容火狐
 }
 //判断点击的类名
 switch(el.className){
 //关闭整个状态
 case "close":
 remove(el.parentNode);
 break;

 //回复评论
 case "hf-btn hf-btn-on":
 reply(el.parentNode.parentNode.parentNode);
 break;

 case "comment-dele":
 operateReply(el);
 break;
 }
 }
 var textarea=lists[i].getElementsByClassName("hf-text")[0];

 //焦点事件
 textarea.onfocus=function(){
 this.parentNode.className='hf hf-on';
 this.value = this.value == '评论…' ? '' : this.value;
 }
 //失焦事件
 textarea.onblur=function(){
 if(this.value==''){
 this.parentNode.className='hf';
 this.value ='评论…';
 }
 // var textarea1=lists[1].getElementsByClassName("hf-text")[1];
 //  //焦点事件1
 // textarea1.onfocus=function(){
 // this.parentNode.className='hf hf-on';
 // this.value = this.value == '评论…' ? '' : this.value;
 // }
 // //失焦事件
 // textarea1.onblur=function(){
 // if(this.value==''){
 // this.parentNode.className='hf';
 // this.value ='评论…';
 // }
 }
 //键盘事件
 textarea.onkeyup=function(){
 var len=this.value.length;
 var textParentNode=this.parentNode;
 var textBtn=textParentNode.children[1];
 var textNub=textParentNode.children[2];
 if(len==0 /*|| len>100*/){
 textBtn.className="hf-btn";
 }else{
 textBtn.className="hf-btn hf-btn-on";
 /*this.style.color="#333"; */
 }
 textNub.innerHTML=len+"/100";
 }
 }
 //遍历结束
 }

    </script>
</div>

<!-- <a href="javascript:;" class="btn-gotop go_to_top hide"><i>置顶</i></a> -->

@endsection